﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace BobcatMultiTouch
{
    /// <summary>
    /// Arguments passed along with the events raised by classes that implement
    /// the IMultiTouchSource interface. These args specify the source index of
    /// the point, its position and so on.
    /// </summary>
    public class TouchArgs : EventArgs
    {
        // Enum for mouse-button states (or equivalent states from other input devices)
        public enum ButtonType
        {
            NONE,
            LEFT,
            MIDDLE,
            RIGHT,
            SCROLL_DOWN,
            SCROLL_UP
        }

        // Constructor..
        public TouchArgs()
        {
            PointIndex = 0; 
            ScreenPosition = new Point();
            ClientPosition = new Point();
            Button = ButtonType.NONE;
            Pressure = 0.0;
        }

        public int PointIndex { get; set; } // Indexes should be zero-based.
        public Point ScreenPosition { get; set; }
        public Point ClientPosition { get; set; }
        public ButtonType Button { get; set; }
        public double Pressure { get; set; } // Range 0.0 to 1.0
    }

    /// <summary>
    /// Arguments passed with the ConfigChangedEvent from sources that
    /// support the IMultiTouchInterface.
    /// </summary>
    public class ConfigChangedArgs : EventArgs
    {
        public string SourceName { get; set; }
        public string XMLConfig { get; set; }
    }


    /// <summary>
    /// An interface that should be implemented by all classes that raise multi-touch events.
    /// This includes the MultiTouchInputManager itself, and any specific sources that it can
    /// manage.
    /// </summary>
    public interface IMultiTouchSource
    {
        /// <summary>
        /// Event raised when a touch-down is detected. Depending on the source, this could be 
        /// a mouse-down event or a finger-down event on a touch screen etc.
        /// </summary>
        event EventHandler<TouchArgs> TouchDownEvent;

        /// <summary>
        /// Event raised when a touch-up is detected. Depending on the source, this could be 
        /// a mouse-up event or a finger-up event on a touch screen etc.
        /// </summary>
        event EventHandler<TouchArgs> TouchUpEvent;

        /// <summary>
        /// Event raised when a touch-move is detected. Depending on the source, this could be 
        /// a mouse-drag event or a finger-move event on a touch screen etc.
        /// </summary>
        event EventHandler<TouchArgs> TouchMoveEvent;

        /// <summary>
        /// Event raised when the config for the source changes. 
        /// </summary>
        event EventHandler<ConfigChangedArgs> ConfigChangedEvent;

        /// <summary>
        /// Function to initialize the source.
        /// </summary>
        void initializeFromXMLConfig(string strXML);

        /// <summary>
        /// Performs any shutdown needed for the source.
        /// </summary>
        void close();

        /// <summary>
        /// Returns the name of the source. This should be a unique name for the source type. 
        /// It may appear in GUIs when selecting between different source types.
        /// </summary>
        string getSourceName();

        /// <summary>
        /// Returns XML config information. This XML should record the config of the source
        /// such that it can be restored by passing it back into initializeFromXML later.
        /// </summary>
        string getXMLConfig();

        /// <summary>
        /// Returns the number of points that this source can support. 
        /// For example, a mouse can only support one point. The wiimote IR
        /// can support 4 points.
        /// </summary>
        int getMaxNumberOfPoints();

        /// <summary>
        /// Returns a 256x256 image that can be used as an icon or in the config screen.
        /// </summary>
        Image getIcon();

        /// <summary>
        /// Returns a UserControl that manages the custom config for this source. You
        /// can return null here if there is no special config necessary.
        /// </summary>
        UserControl getConfigControl();
    }
}
